<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui"
    xmlns:f="http://java.sun.com/jsf/core">
<h:head>
    <title>SocialMap</title>
    <f:metadata>
        <f:event listener="#{loginBean.verifyUseLogin}" type="preRenderView">
        </f:event>
    </f:metadata>
</h:head>
<h:body>
    <h:form id="data">
        <p:growl id="growl" showDetail="true" sticky="true" autoUpdate="True" />
        <h:outputText value="Server runnig: True" />
        <p:dataTable id="dataTable" var="event" value="#{loginBean.events}" widgetVar="eventTable"
            emptyMessage="No events found with given criteria" filteredValue="#{loginBean.filteredEvents}"
            rowKey="#{event.id}" selection="#{loginBean.selectedEvents}" selectionMode="multiple" paginator="true"
            rows="10"
            paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
            rowsPerPageTemplate="5,10,15">
            <f:facet name="header">
                <p:outputPanel>
                    <h:outputText value="Created Events" />
                </p:outputPanel>
            </f:facet>
            <p:column id="idColumn" filterBy="id" headerText="ID" filterMatchMode="contains">
                #{event.id} 
            </p:column>
            <p:column id="nameColumn" filterBy="name" headerText="Name" filterMatchMode="contains">
                #{event.name}"
            </p:column>
            <p:column id="macidColumn" filterBy="macid" headerText="Mac-ID" filterMatchMode="contains">
                #{event.macid}"
            </p:column>
            <p:column id="startColumn" filterBy="start" headerText="Start" filterMatchMode="contains">
                #{event.start}"
            </p:column>
            <p:column id="endColumn" filterBy="end" headerText="End" filterMatchMode="contains">
                #{event.end}"
            </p:column>
            <p:column id="cordsColumn" filterBy="cords" headerText="Map-Coordinates" filterMatchMode="contains">
                #{event.cords}"
            </p:column>
            <p:column id="descriptionColumn" filterBy="description" headerText="Description" filterMatchMode="contains">
                #{event.description}"
            </p:column>
            <p:column id="categoriesColumn" filterBy="categories" headerText="Categories" filterMatchMode="exact"
                filterOptions="#{loginBean.typOptions}">
                #{event.categories}"
            </p:column>
            <p:column id="createdColumn" filterBy="created" headerText="Created" filterMatchMode="contains">
                #{event.created}"
            </p:column>
            <p:column id="editedColumn" filterBy="edited" headerText="Edited" filterMatchMode="contains">
                #{event.edited}"
            </p:column>
        </p:dataTable>
        <p:commandButton type="button" value="Refresh" icon="ui-icon-document"
            actionListener="#{loginBean.refreshEvents}" update="data" />
        <p:commandButton id="deleteS" value="Delete Selected" actionListener="#{loginBean.deleteSelected}" update="data" />
        <p:commandButton id="deleteA" value="Delete All" actionListener="#{loginBean.deleteAll}" update="data" />
    </h:form>
</h:body>
</html>